package com.miaosmart.service;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.miaosmart.entity.MatchRecord;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class GameRecordService {

    private final IMatchRecordService matchRecordService;

    public Response getGameRecord(Request request) {

        List<MatchRecord> list = matchRecordService.query().eq("game_id", request.gameId)
                .orderBy(true, false, "created_at")
                .list();

        return new Response(list);
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public record Request(
            @JsonProperty(required = true, value = "gameId") @JsonPropertyDescription("游戏ID") String gameId) {
    }

    public record Response(List<MatchRecord> list) {
    }

}
